/**
 * 
 */
package com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.voip;

import com.alstudio.module.xmpp.protocol.xmpp.packact.ALXmppDomainConfig;
import com.alstudio.module.xmpp.protocol.xmpp.packact.IQNameSpace;
import com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.AlXmlTag;
import com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.BaseIQTemplate;
import com.alstudio.module.xmpp.request.ALUiXmppRequestData;

/**
 * 构造拨打voip电话iq
 * 
 * @author alonso lee
 * 
 */
public class MakeCallIQCreator extends BaseIQTemplate {

	private String domain;
	private ALUiXmppRequestData data;

	public MakeCallIQCreator(ALUiXmppRequestData data, String domain) {
		// TODO Auto-generated constructor stub
		this.data = data; 
		this.domain = domain;
	}

	@Override
	public String getIQXml() {
		// TODO Auto-generated method stub
		AlXmlTag jidTag = new AlXmlTag("jid");
		jidTag.setText(data.getJid());
		mALIQCreator.setNs(IQNameSpace.NS_MAKE_VOIP_CALL);
		to = ALXmppDomainConfig.getALXmppDomainConfig().getDomainByNameSpace(mALIQCreator.getNs());
		mALIQCreator.setTo(to + domain);
		mALIQCreator.setType(IQ_TYPE_GET);
		tagList.add(jidTag);
		AlXmlTag costType = new AlXmlTag("costtype");
		costType.setText(data.getIntData()+"");
		tagList.add(costType);
		
		String xml = "";
		try {
			xml = mALIQCreator.getXml();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return xml;
	}
	
}
